<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Completely remove a phar archive from disk and from memory</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="phar.stopbuffering.html">« Phar::stopBuffering</a></li>
      <li style="float: right;"><a href="phar.webphar.html">Phar::webPhar »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.phar.html">Phar</a></li>
    <li>Completely remove a phar archive from disk and from memory</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="phar.unlinkarchive" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Phar::unlinkArchive</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0, PHP 7, PHP 8, PECL phar &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Phar::unlinkArchive</span> &mdash; <span class="dc-title">Completely remove a phar archive from disk and from memory</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-phar.unlinkarchive-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">final</span> <span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><strong>Phar::unlinkArchive</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span>): <span class="type">bool</span></div>

  <p class="para rdfs-comment">
   Removes a phar archive from disk and memory.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-phar.unlinkarchive-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">filename</code></dt>

     <dd>

      <p class="para">
       The path on disk to the phar archive.
      </p>
     </dd>

    
   </dl>

  </p>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-phar.unlinkarchive-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>true</code></strong>， 或者在失败时返回 <strong><code>false</code></strong>。
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-phar.unlinkarchive-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   <span class="classname"><a href="class.pharexception.html" class="classname">PharException</a></span> is thrown if there are any open file pointers to
   the phar archive, or any existing <span class="classname"><a href="class.phar.html" class="classname">Phar</a></span>, <span class="classname"><a href="class.phardata.html" class="classname">PharData</a></span>,
   or <span class="classname"><a href="class.pharfileinfo.html" class="classname">PharFileInfo</a></span> objects referring to the phar archive.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-phar.unlinkarchive-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-758">
    <p><strong>示例 #1 A <span class="function"><strong>Phar::unlinkArchive()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;simple&nbsp;usage<br /></span><span style="color: #0000BB">Phar</span><span style="color: #007700">::</span><span style="color: #0000BB">unlinkArchive</span><span style="color: #007700">(</span><span style="color: #DD0000">'/path/to/my.phar'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;more&nbsp;common&nbsp;example:<br /></span><span style="color: #0000BB">$p&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Phar</span><span style="color: #007700">(</span><span style="color: #DD0000">'my.phar'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$fp&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #DD0000">'phar://my.phar/file.txt'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'r'</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">//&nbsp;this&nbsp;creates&nbsp;'my.phar.gz'<br /></span><span style="color: #0000BB">$gp&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$p</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">compress</span><span style="color: #007700">(</span><span style="color: #0000BB">Phar</span><span style="color: #007700">::</span><span style="color: #0000BB">GZ</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">//&nbsp;remove&nbsp;all&nbsp;references&nbsp;to&nbsp;the&nbsp;archive<br /></span><span style="color: #007700">unset(</span><span style="color: #0000BB">$p</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">fclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">//&nbsp;now&nbsp;remove&nbsp;all&nbsp;traces&nbsp;of&nbsp;the&nbsp;archive<br /></span><span style="color: #0000BB">Phar</span><span style="color: #007700">::</span><span style="color: #0000BB">unlinkArchive</span><span style="color: #007700">(</span><span style="color: #DD0000">'my.phar'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-phar.unlinkarchive-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="phar.delete.html" class="function" rel="rdfs-seeAlso">Phar::delete()</a> - 删除 phar 档案中的一个文件</span></li>
    <li class="member"><span class="function"><a href="phar.offsetunset.html" class="function" rel="rdfs-seeAlso">Phar::offsetUnset()</a> - Remove a file from a phar</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>